package com.crt.nexus.oauth.authorization;

import com.crt.nexus.core.spring.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.stereotype.Component;

@Component
public class AuthenticationContext {

    private AuthenticationProcessor processor;

    public AuthenticationProvider get(String type) {
        Class<?> clazz = processor.get(type);
        return (AuthenticationProvider) SpringContextHolder.getBean(clazz);
    }

    @Autowired
    public void setProcessor(AuthenticationProcessor processor) {
        this.processor = processor;
    }

}
